<?php
/**
 * Apc缓存类
 */
class ApcCache extends CacheHelper
{


    /**
     * 架构函数
     * @access public
     */
    function __construct($options='')
    {
		if(!function_exists('apc_cache_info')) throw new YucyException('您的运行环境不支持:Apc');
		
		$this->expire = isset($options['expire'])? $options['expire'] : 60;
        $this->type = 'Apc';
    }

    /**
     * 读取缓存
     * @access public
     * @param string $name 缓存变量名
     * @return mixed
     */
     function get($name)
     {
		$this->Q(1);
        return apc_fetch($name);
     }

    /**
     * 写入缓存
     * @access public
     * @param string $name 缓存变量名
     * @param mixed $value  存储数据
     * @return boolen
     */
     function set($name, $value, $ttl = null)
     {
		$this->W(1);
		$expire = isset($ttl) && is_int($ttl) ? $ttl : $this->expire;

        return apc_store($name, $value, $expire);
     }

    /**
     * 删除缓存
     * @access public
     * @param string $name 缓存变量名
     * @return boolen
     */
     function delete($name)
     {
         return apc_delete($name);
     }

    /**
     * 清除缓存
     * @access public
     * @return boolen
     */
    function clear()
    {
        return apc_clear_cache();
    }

}